package com.example.mountainwalker.controller;

import com.example.mountainwalker.entity.HotelInfo;
import com.example.mountainwalker.service.HotelService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/hot")
public class HotelController {

    private final HotelService hotelService;

    public HotelController(HotelService hotelService) {
        this.hotelService = hotelService;
    }

    @GetMapping("/list")
    public List<HotelInfo> getAllHotels() {
        return hotelService.getAllHotel();
    }

    @GetMapping("/search/name")
    public List<HotelInfo> searchHotelsByName(@RequestParam String name) {
        return hotelService.searchHotelsByName(name);
    }

    @GetMapping("/search/region")
    public List<HotelInfo> searchHotelsByRegion(@RequestParam int regionId) {
        return hotelService.searchHotelsByRegion(regionId);
    }

    @GetMapping("/search/scenic-spot")
    public List<HotelInfo> searchHotelsByScenicSpot(@RequestParam int scenicSpotId) {
        return hotelService.searchHotelsByScenicSpot(scenicSpotId);
    }

    @PostMapping("/add")
    public int addHotel(@RequestBody HotelInfo hotelInfo) {
        return hotelService.addHotel(hotelInfo);
    }

    @PutMapping("/update")
    public int updateHotel(@RequestBody HotelInfo hotelInfo) {
        return hotelService.updateHotel(hotelInfo);
    }

    @DeleteMapping("/delete/{id}")
    public int deleteHotel(@PathVariable int id) {
        return hotelService.deleteHotel(id);
    }
}